<template>
	<view>
		<uniNavBar
			:title='title' 
			leftIcon="left"
			leftText="返回"
			fixed='true'
			status-bar='true'
			@clickLeft="Back"
		></uniNavBar>
		<scroll-view scroll-y="true" >
			<view>
				<uni-card>
					<PathItem :data="pathData" :disable='false'></PathItem>
					<ConfigItem :dataList="userData" :disable="false"></ConfigItem>
				</uni-card>
				<uni-card>
					<view class="shop-info">订单信息</view>
					<Lines/>
					<ConfigItem :dataList="orderInfo" :disable="false"></ConfigItem>
				</uni-card>
				<uni-card>
					<view class="shop-info">商品信息</view>
					<Lines/>
					<ConfigItem :dataList="shopData" :disable="false"></ConfigItem>
				</uni-card>
				<uni-card>
					<OrderItem :orderData="orderData" :item="ItemData" :disable="false"></OrderItem>
				</uni-card>
				<!-- <order :dataList="goodsList" :disable="false"></order> -->
				<uni-card>
					<view class="shop-info">其他信息</view>
					<Lines/>
					<ConfigItem :dataList="otherData" :disable="false"></ConfigItem>
				</uni-card>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import Lines from '@/components/common/Lines.vue'
	import $http from '../../common/api/request.js'
	import {mapState,mapMutations} from 'vuex'
	import PathItem from '../../components/path/path-item.vue'
	import uniNavBar from '@/components/uni/uni-nav-bar/uni-nav-bar.vue'
	import ConfigItem from '@/components/my-config/my-config-item.vue'
	import order from '../../components/order/order.vue'
	import OrderItem from '@/components/order/order-item.vue'
	export default {
		data() {
			return {
				orderData:[],
				ItemData:{},
				title:'',
				pathData:{},
				goodsList:[],
				userData:[
					{
						title:'联系电话',
						tips:''
					},
					{
						title:'发货方式',
						tips:'快递配送'
					},
					{
						title:'下单信息',
						user:'',
						tips:''
					}
				],
				orderInfo:[
					{
						title:'订单编号',
						info:''
					},
					{
						title:'下单时间',
						info:''
					},
					{
						title:'支付方式',
						info:'线上支付'
					},
				],
				shopData:[
					{
						title:'商品总价',
						tips:''
					},{
						title:'运费',
						tips:''
					},{
						user:'合计￥',
						tips:''
					}
				],
				otherData:[
					{
						title:'额外需求'
					}
				]
			}
		},
		components:{
			uniNavBar,
			PathItem,
			ConfigItem,
			Lines,
			order,
			OrderItem
		},
		computed:{
			
		},
		onLoad(e) {
			if(e.data){
				this.ItemData = JSON.parse(e.data)
				this.goodsList.push(this.ItemData)
				this.getAddress()
				this.getInfo(this.ItemData)
				this.getOrderDetialData(this.ItemData)
			}
			if(this.ItemData.order_status == 1){
				this.title = '待付款'
			}else if(this.ItemData.order_status == 2){
				this.title = '待配送'
			}else if(this.ItemData.order_status == 3){
				this.title = '待收货'
			}else if(this.ItemData.order_status == 4){
				this.title = '待评价'
			}
		},
		methods: {
			Back(){
				uni.navigateBack({
					delta:1
				})
			},
			// 获取地址
			getAddress(){
				const _this = this;
				$http.request({
					url:'/getAddressItem',
					method:'POST',
					header:{
						token:true
					},
					data:{
						addressId:_this.ItemData.address_id,
						userId: _this.ItemData.uid,
					}
				}).then((res)=>{
					this.pathData = res[0]
				})
			},
			getInfo(data){
				// 用户信息
				this.userData[0].tips = data.phone,
				this.userData[2].user = data.storeName,
				this.userData[2].tips = data.phone
				// 订单信息
				this.orderInfo[0].info = data.order_id,
				this.orderInfo[1].info = data.createTime,
				
				// 商品信息
				this.shopData[0].tips ='￥'+ data.unitPrice
				this.shopData[1].tips = '￥'+'0',
				this.shopData[2].tips = data.unitPrice
			},
			getOrderDetialData(data){
				$http.request({
					url:'/getOrderDetialData',
					method:'POST',
					header:{
						token:true
					},
					data:{
						orderId:data.order_id
					}
				}).then((res)=>{
					this.orderData = res
				})
			}
		}
	}
</script>

<style scoped>
.shop-info{
	margin-left: 10rpx;
	font-size: 30rpx;
	font-weight: bold;
}

</style>
